import request, { QuickResponseData } from '@/utils/request'
import { Product as api } from './index'
import { Product } from '@/types/product'
//删除
export const deleteProduct = (id: string) => {
  return request({
    url: `${api}/${id}`,
    method: 'DELETE'
  })
}
//获取产品分页列表  get 获取   product 产品  page 分页  list  列表
// export const getProductPageList = (params: object): Promise<QuickResponseData<Array<Product>>> => {
//   return request<QuickResponseData<Array<Product>>>({
//     url: api,
//     method: 'GET',
//     params
//   })
// }
//获取产品列表
export const getProductList = (): Promise<QuickResponseData<Array<Product>>> => {
  return request<QuickResponseData<Array<Product>>>({
    url: api,
    method: 'GET'
  })
}
//新增
export const addProduct = (data: Product) => {
  return request({
    url: api,
    method: 'POST',
    data
  })
}
//修改
export const updateProduct = (data: Product) => {
  const { id } = data
  return request({
    url: `${api}/${id}`,
    method: 'PUT',
    data
  })
}
